import java.awt.Graphics;
import java.awt.TextField;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class Plateau extends JPanel{

	public JFrame fenetre;
	public ChargementImg fond;
	public int positionPlateauX = 100;
	public int positionPlateauY = 100;
	public int tailleCase = 30;
	
	CaseSudoku cs ;
	
	public CaseSudoku[][] allCaseSudoku = new CaseSudoku[9][9];
	
	public Plateau(JFrame fenetre) {
		this.fenetre = fenetre;
		
	}
	
	public void initialisationPlateau(int[][] data) {
		this.fond = new ChargementImg(new ImageIcon("assets/sudoku.png").getImage(), positionPlateauX, positionPlateauY);
		//fenetre.add(fond);
		
		createAllCaseSudoku(data);
		
		actualisationAffichage();
	}
	
	private void createAllCaseSudoku(int[][] data) {
		for(int i = 0; i<9; i++) {
			for(int j = 0; j<9; j++) {
				allCaseSudoku[i][j] = new CaseSudoku(i*tailleCase + positionPlateauX +tailleCase/2, j*tailleCase + positionPlateauY+tailleCase/2, String.valueOf(data[i][j]));
				//this.add(allCaseSudoku[i][j]);
			}
		}
		
	}
	
	public void actualisationAffichage() {
		fenetre.add(this);
	}
	
	public void paintComponent(Graphics g) {
		fond.paintComponent(g);
		for(int i = 0; i<9; i++) {
			for(int j = 0; j<9; j++) {
				//if (cs.getTrouver(i,j) == true) {
					//TODO
					//n'afficher que les cases marque comme trouve
					allCaseSudoku[i][j].paintComponent(g);
				//}else{
					//paint case vide
				
			}
		}
      
    }
	
}
